<?php if (isset($menus)):?>
	<?php if($this->beginCache('menu-render-'.$this->menu_id, array('duration'=>7200))) { ?>
      <div class="navbar"> <!-- Navigation bar-->
      	<div class="navbar-inner">
	  		<div class="container">
		  		<a data-toggle="collapse" data-target=".nav-collapse" class="btn btn-navbar">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</a>
		      	<div class="nav-collapse">
		            <ul class="nav">      	
			        	<?php foreach ($menus as $menu) :?>	
			        	<?php 
			        		$second_level_menus=MenuBlock::getMenuItems($menu['id'],$this->menu_id);
			        		if(count($second_level_menus)>0){
			        			echo '<li class="dropdown">';
			        		}else echo '<li>';
			        	?>
			          		<a <?php if(count($second_level_menus)>0): ?> data-toggle="dropdown" class="dropdown-toggle" <?php endif;?> href="<?php echo $menu['link'];?>" <?php echo isset($_GET['slug'])&&$_GET['slug']==$menu['link']?'class="active"':'';?>><?php echo $menu['name'];?><?php if(count($second_level_menus)>0): ?><b class="caret"></b><?php endif;?></a>
			          		<?php 
			          			
								if(count($second_level_menus)>0) : ?>
								<ul class="dropdown-menu">
									<?php foreach ($second_level_menus as $second_menu) : ?>
											<li><a href="<?php echo $second_menu['link'];?>"><?php echo $second_menu['name'];?></a>										
												<?php 
							          			$third_level_menus=MenuBlock::getMenuItems($second_menu['id'],$this->menu_id);
												if(count($third_level_menus)>0) : ?>
												<ul class="menu_level_3">
													<?php foreach ($third_level_menus as $third_menu) : ?>
														<li><a href="<?php echo $third_menu['link'];?>"><?php echo $third_menu['name'];?></a></li>
													<?php endforeach; ?>
												</ul>
												<?php endif; ?>
											</li>
									<?php endforeach; ?>
								</ul>
								<?php endif; ?>	
							</li>
			          	<?php endforeach;?>
			        </ul>
		       	</div>
	       	</div>
       	</div>
      </div>      
   <?php $this->endCache(); } ?>
<?php endif;?>
